Temporary table data persists only during the current Apache Hive session. Hive drops the table at the end of the session. If
you use the name of a permanent table to create the temporary table,
the permanent table is inaccessible during the session unless you drop
or rename the temporary table. You can create a temporary table having the same name as another user's temporary table because user sessions are independent. Temporary tables do not support partitioned columns and indexes.
- Create a temporary table having one string column.
- CREATE TEMPORARY TABLE tmp1 (tname varchar(64));
- Create a temporary table using the CREATE TABLE AS SELECT (CTAS) statement.
- CREATE TEMPORARY TABLE tmp2 AS SELECT c2, c3, c4 FROM mytable;
- Create a temporary table using the CREATE TEMPORARY TABLE LIKE statement.
- CREATE TEMPORARY TABLE tmp3 LIKE tmp1;
Below are the some of the limitations of Hive temporary tables:
- Partition columns option is not supported on temporary tables.
- Creating indexes on temporary table is not allowed.
- A temporary table with the same name as a permanent table will cause all references to that table name to resolve to the temporary table.
- The user cannot access the permanent table with same name as temporary tables during that session without dropping or renaming the temporary table.
No comments:
Post a Comment